/* 拣货单
 */

import { postRequest, getRequest } from '@/lib/axios'
interface CreateData {
  load_order_id?: number // 装车单id，如果没有可以不填
  type: number // type=1,合并添加；2逐单添加
  source_orders: {
    related_id: number //对应订单id
    related_type: number // 订单类型，1采退PurchaseOrder 2访销Order 3调拨TransferOrder
  }[]
  remark: string
}
interface PickOrderApi {
  queryList: (param: any) => Promise<any>
  detail: (param) => Promise<any>
  print: (param: { id: number }) => Promise<any>
  create: (data: CreateData) => Promise<any>
  cancel: (data: { id: number; detail_id?: number }) => Promise<any>
}
export const pickOrderApi: PickOrderApi = {
  // 拣货单列表
  queryList: (param) => {
    return getRequest('/pick_order/list', param)
  },
  // 详情
  detail: (param) => {
    return getRequest('/pick_order/detail', param)
  },
  // 打印
  print: (param) => {
    return getRequest('/pick_order/print-message', param)
  },
  // 生成拣货单
  create: (data) => {
    return postRequest('/pick_order/add', data)
  },
  // 取消
  cancel: (data) => {
    return postRequest('/pick_order/cancel-pick', data)
  }
}
